<?php
namespace app\api;

use service\UtilService;
use app\common\model as M;

class ApiAuth extends \app\api\ApiBase {
    protected function _initialize()
    {
        parent::_initialize();
        try {
            if ( !$this->NoWechantVisitWhite() ) {
                if( empty($this->userInfo) ) return $this->returnFail('请登录后再操作',201);
                if( $this->userInfo['status'] != 1 ) throw new \Exception('已被禁止登陆!');
            }
        } catch ( \Exception $e ) {
            M\User::clear_login();
            return $this->returnFail($e->getMessage());
        }
    }

    /*
     * 无需登录校验白名单
     * */
    public static function WhiteList()
    {
        return [];
    }

    /**
     * 获取列表
     * @Author   FW
     * @DateTime 2021-01-13
     * @Email    123763712@qq.com
     * @return   [type]           [description]
     */
    public function get_list ()
    {
        $where = $this->request->get();
        $where['page']  = $where['page'] ?? 1;
        $where['limit'] = $where['limit'] ?? 20;
        $where['uid']   = $this->uid;
        return $this->returnSuccess($this->model::getList($where));
    }
} // Class End